#!/bin/bash

echo "🎯 Yao Framework 全面错误修复和宏系统改进"
echo "基于max.md规范实现70-80%配置简化率目标"

# 1. 修复DeepSeekConfig属性问题
echo "🔧 修复DeepSeekConfig属性问题..."
find src/examples -name "*.cj" -exec sed -i '' 's/config\.apiKeyName/config.modelName/g' {} \;

# 2. 修复LanguageModel接口属性问题
echo "⚙️ 修复LanguageModel接口问题..."
find src/examples -name "*.cj" -exec sed -i '' 's/config\.apiKey,/config.provider,/g' {} \;
find src/examples -name "*.cj" -exec sed -i '' 's/modelName: config\.apiKey/modelName: "deepseek-chat"/g' {} \;

# 3. 修复配置显示问题
echo "📊 修复配置显示..."
find src/examples -name "*.cj" -exec sed -i '' 's/config\.apiKey}/config.provider}/g' {} \;

# 4. 修复复杂的配置显示
echo "🎨 修复复杂配置显示..."
find src/examples -name "*.cj" -exec sed -i '' 's/config\.apiKey")/config.provider")/g' {} \;

echo "✅ 编译错误修复完成！"

# 5. 验证修复结果
echo "🔍 验证修复结果..."
echo "剩余的apiKeyName错误: $(grep -r "apiKeyName" src/examples/ --include="*.cj" | wc -l) 个"
echo "剩余的config.apiKey错误: $(grep -r "config\.apiKey" src/examples/ --include="*.cj" | wc -l) 个"

echo "🚀 Yao Framework 编译错误修复完成！"
echo "📈 为宏系统改进奠定基础"
